package com.linchong.concurrency.chapter5;

import java.util.stream.IntStream;

/**
 * @Author:linchong
 * @CreateTime:2020-01-03 22:04
 * @Description:join
 */
public class ThreadJoin2 {
	public static void main(String[] args) throws InterruptedException {
		Thread t1 = new Thread(() -> {
			try {
				System.out.println("t1 is running.");
				Thread.sleep(10_000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		});
		t1.start();
		t1.join(100, 10);
		System.out.println("all of tasks finish done;");
		IntStream.range(1, 1000).
				forEach(i -> System.out.println(Thread.currentThread().getName() + "->" + i));


		//线程常运行
		Thread.currentThread().join();
	}

}
